/* 
 * File:   PS2Keyboard.h
 * Author: frank
 *
 * Created on November 23, 2014, 8:58 PM
 */

#ifndef PS2KEYBOARD_H
#define	PS2KEYBOARD_H

// This module will control the Keyboard and receive the data.
// However, it will not translate the keys to characters.
// Use the call back to get the key pressed or released.

typedef enum {
    PS2K_SCRL_LOCK = 0x01,
    PS2K_NUM_LOCK = 0x02,
    PS2K_CAPS_LOCK = 0x04
} PS2K_LEDS;

typedef enum {
    PS2K_GET_SET = 0x00,
    PS2K_SET_1 = 0x01,
    PS2K_SET_2 = 0x02,
    PS2K_SET_3 = 0x03
} PS2K_SCAN_CODE_SETS;

typedef enum {
    PS2K_DELAY_250ms = 0x00,
    PS2K_DELAY_500ms = 0x20,
    PS2K_DELAY_750ms = 0x40,
    PS2K_DELAY_1000ms = 0x60
} PS2K_REPEAT_DELAY;


// Up to 3 bytes may be sent by the keyboard for one key.
// Code1 will be the command or the beginning of a key press/release
typedef void (*PS2Keyboard_Callback_Function)(unsigned char code1, unsigned char code2, unsigned char code3);
void PS2K_Callback(PS2Keyboard_Callback_Function function);

void PS2K_Init();
void PS2K_ResetKeyboard();                  // Returns 0xFA, 0xAA for pass test
void PS2K_Echo();                           // Returns 0xEE
void PS2K_SetLED(unsigned char data);

void PS2K_SetScanCodeSet(PS2K_SCAN_CODE_SETS set);
//void PS2K_GetScanCodeSet(); // Not working with my 2 keyboards???
void PS2K_EnableScanning();
void PS2K_DisableScanning();
void PS2K_SetToDefaults();
void PS2K_SetTypematicRateDelay(unsigned char repeatRate, PS2K_REPEAT_DELAY delay);
void PS2K_ResendLastByte();


#endif	/* PS2KEYBOARD_H */

